@{layout('')}

<!DOCTYPE html>
<html>
<head>
    <title>Server-Sent Events</title>
    <meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=10" />
	<meta name="format-detection" content="telephone=no"/>
	<meta name="viewport" content="width=1024, user-scalable=yes" />
	<meta name="robots" content="all,follow" />
</head>
<body>

	<div id="message"></div>

	<script type="text/javascript">

		function init() {
	  		var el = document.getElementById('message');
			var obj = new EventSource('/one-way-messaging/');

			obj.onmessage = function(ev) {
	  			el.innerHTML = ev.data + '<br />' + el.innerHTML;
	  		};

	  		obj.addEventListener('end', function() {
	  			el.innerHTML = '----- end<br />' + el.innerHTML;
	  		}, true);

	  		obj.onerror = function(e) {
	  			el.innerHTML = '----- error<br />' + el.innerHTML;
	  		};
		}

		setTimeout(init, 500);

	</script>

</body>
</html>